﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JHT.SimpleTaskSystem.EntityFramework.Mapper
{
    public class SimplyTaskMapping : EntityTypeConfiguration<SimpleTask>
    {
        public SimplyTaskMapping()
        {
            ToTable("SimpleTasks");

            this.HasKey(p => p.Id);
            this.Property(p => p.Id).HasColumnName("TaskId").HasColumnType("bigint").HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity).IsRequired();

            this.Property(p => p.State).HasColumnName("TaskState").HasColumnType("int").IsRequired();
            this.Property(p => p.CreationTime).HasColumnType("datetime").HasColumnName("CreationTime").IsRequired();
            this.Property(p => p.AssignedPersonId).HasColumnName("FKAssignedPersonId").HasColumnType("int").IsOptional();

            this.HasOptional(p => p.AssignedPerson).WithMany(t => t.SimpleTasks);//1to0,1toMany 

        }
    }
}
